var e = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("util.js"));

module.exports = {
    convertSymbolToText: function(e, r) {
        for (var t in r) if (t === e) return r[e];
    },
    convertCurrencyToCNY: function(e, r) {
        var t = e / (1 - {
            wechat_base_fee: 0,
            wechat_commission: .03
        }.wechat_commission);
        return t ? Math.ceil(r.CNY * t) / 100 : 0;
    },
    convertCNYToApproachCent: function(e, r) {
        return Number(parseInt(e / r.CNY * 100));
    },
    convertCurrencyToUSD: function(e) {
        return e = (e / 100).toFixed(2);
    },
    convertSessionStatus: function(e) {
        if (!e) return "";
        var r = e.status, t = e.focus_user_is_teacher, s = e.operater;
        e.update_time, e.type, e.session_start_time;
        switch ("string" == typeof r && (r = r.toLowerCase()), r) {
          case "0":
            return t ? "action" : "waiting";

          case "3":
            return t ? "waiting" : "action";

          case "1":
          case "2":
          case "4":
          case "z":
          case "p":
            return "";

          case "5":
          case "o":
            return t && 2 == s || !t && 1 == s ? "waiting" : "action";

          case "6":
          case "w":
            return "upcoming";

          case "7":
            return t ? "waiting" : "action";

          case "c":
          case "s":
            return t && 2 == s || !t && 1 == s ? "waiting" : "action";

          case "e":
          case "f":
          case "g":
            return "";

          case "h":
            return "waiting";

          case "q":
            return "action";

          case "9":
            return t && 2 == s || !t && 1 == s ? "waiting" : "action";

          case "x":
            return "";
        }
    },
    convertSessionProblemStatus: function(e) {
        var r, t = e.focus_user_is_teacher, s = e.operater;
        switch (e.status) {
          case "C":
          case "S":
          case "O":
          case "9":
            r = t && 2 == s || !t && 1 == s ? "waiting" : "action";
            break;

          case "H":
            r = "waiting";
            break;

          default:
            r = "";
        }
        return r;
    },
    convertSessionStatusDesc: function(r, t) {
        if (!r) return "";
        if ("underfined" != typeof r.focus_user_is_teacher) s = r.focus_user_is_teacher; else var s = "1" != r.user_type;
        if (void 0 !== r.type) a = r.type; else var a = r.session_type;
        var n = r.status, c = r.operater, u = (r.update_time, r.session_start_time);
        switch ("string" == typeof n && (n = n.toLowerCase()), n) {
          case "0":
          case "o":
            return s ? "课时请求" : "等待" + r.oppo_user_obj.nickname + "答复";

          case "3":
          case "5":
            return s ? "等待" + r.oppo_user_obj.nickname + "答复" : "课时修改请求";

          case "9":
            return s && 2 == c || !s && 1 == c ? "等待" + r.oppo_user_obj.nickname + "答复" : "课时修改请求";

          case "1":
          case "2":
          case "4":
          case "z":
          case "p":
          case "x":
            return "已取消";

          case "6":
          case "w":
            return Date.parse(u) == Date.parse(new Date()) ? "进行中" : e.default.countDown(u);

          case "7":
            return s ? "等待" + r.oppo_user_obj.nickname + "答复" : "确认课时完成";

          case "c":
            return "课时问题";

          case "s":
            return "请求重新安排课时";

          case "e":
            return 2 == a ? "已完成" : "已取消";

          case "f":
          case "g":
            return "已完成";

          case "h":
            return "italki处理";

          case "q":
            return "请求新课时时间";
        }
    },
    convertPackageStatusDesc: function(e) {
        if (!e) return "";
        if (void 0 !== e.focus_user_is_teacher) r = e.focus_user_is_teacher; else var r = "1" != e.user_type;
        var t = e.status, s = e.operater;
        switch ("string" == typeof t && (t = t.toLowerCase()), t) {
          case "0":
            return r ? "学生发起课时包请求" : "等待答复";

          case "3":
          case "b":
            return r ? "等待答复" : "课时包终止请求";

          case "6":
            return r ? "修改课时包请求" : "等待答复";

          case "c":
            return r ? "课时包终止请求" : "等待答复";

          case "5":
            return s && s > 0 ? "课时包延期请求" : "课时包达成协议";

          case "7":
            return "课时包终止";

          case "f":
            return "已完成";

          case "z":
            return "已冻结";

          case "1":
          case "2":
          case "4":
            return "已取消";
        }
    },
    convertSessionProblemStatusDesc: function(e) {
        if (void 0 !== e.focus_user_is_teacher) r = e.focus_user_is_teacher; else var r = "1" != e.user_type;
        var t, s = e.operater;
        switch (e.status) {
          case "C":
            t = "课时问题";
            break;

          case "S":
            t = r && 2 == s || !r && 1 == s ? "等待答复" : "请求重新安排课时";
            break;

          case "O":
          case "9":
            t = r && 2 == s || !r && 1 == s ? "等待答复" : "需要操作";
            break;

          case "H":
            t = "争议";
            break;

          default:
            t = "已解决";
        }
        return t;
    },
    sessionOperationDesc: function(e, r, t, s) {
        function a(e, r, t, s) {
            switch (e) {
              case 1:
                return r;

              case 2:
                return t;

              default:
                return s;
            }
        }
        function n() {
            var e = arguments;
            switch (u) {
              case "2":
                return e[1];

              case "3":
                return e[2];

              default:
                return e[0];
            }
        }
        if (!e) return "";
        var c = r, u = e.session_type, i = e.id, o = r.status, _ = r.explain, f = r.operater, p = s.length > 1 && t > 1 ? s[t - 1].status : "";
        switch (1 === e.user_type ? (e.current_user_name, e.oppo_user_obj.nickname) : (e.oppo_user_obj.nickname, 
        e.current_user_name), o) {
          case "0":
            return n("学生发送了一个新的课时请求。等待教师的回应。", "学生发送了一个新的课时请求。等待教师的回应。", "学生发送了一个试用课时的请求。等待教师的回应。");

          case "1":
            return n("学生取消了课时请求。", "", "学生取消了试用请求。");

          case "2":
            return "该课时请求已过期。";

          case "3":
            return n("教师更改了课时请求。", "", "教师更改了试用请求。");

          case "4":
            return n("教师拒绝了课时请求。", "教师拒绝了课时请求。", "教师拒绝了试用请求。");

          case "6":
            switch (p) {
              case "3":
                return "学生接受了课时请求的更改。";

              case "5":
                return "N" == _ ? a(f, "学生拒绝了教师的请求。", "老师拒绝了学生的请求。", "课时将在 24 小时内开始，将不可再修改。请求的更改已经被 italki 自动删除。") : a(f, "学生接受了课时请求的更改。 该课时已被重新预约。", "教师接受了课时请求的更改。该课时已被重新预约", "课时将在 24 小时内开始，将不可再修改。请求的更改已经被 italki 自动删除。");

              case "9":
                return a(f, "学生已拒绝取消课时。该课时将按原计划进行。", "教师已拒绝取消课时。该课时将按原计划进行。", "该取消请求已被 italki 撤消。");

              default:
                return 10 == f ? "italki 更改了课时日期与时间。" : "课时已预约。（课时 ID:" + i + "）";
            }
            break;

          case "5":
            return a(f, "学生请求修改课时的日期和时间。等待教师的回应。", "教师请求修改课时的日期和时间。等待学生的回应。", "");

          case "7":
            return "课时结束时间已过。";

          case "C":
          case "S":
            return a(f, "学生声明该课时存在问题。", "教师声明该课时存在问题。", "");

          case "Q":
            return "O" != p ? a(f, "学生已接受重新安排一个课时。", "教师已接受重新安排一个课时。", "先前重新预约的请求已超时。课时还需要再次重新预约。") : "";

          case "O":
            return a(f, "学生请求重新安排一个新的课时日期和时间。", "教师请求安排一个新的课时日期和时间。", "");

          case "W":
            return a(f, "学生接受了教师的请求。", "教师接受了学生的请求。", "");

          case "H":
            return a(f, "学生拒绝了教师的请求。", "老师拒绝了学生的请求。", "");

          case "P":
            return a(f, "学生同意该课时没有正常完成。已经在课时包内重新增加了一个课时。", "教师同意该课时没有正常完成。已经在课时包内重新增加了一个课时", "该课时已经被 italki 取消。");

          case "E":
            if ("2" == c.session_type) return a(f, "学生同意该课时已经完成。", "教师同意该课时已经完成。", "该课时被视为完成。");
            var l = c.itc_usd / 100, w = "";
            return l > 0 && (w += "$" + l + "USD信用点数已转给教师。"), e.problem_refund > 0 && (w += "$" + e.problem_refund / 100 + "USD信用点数已转给学生。"), 
            w;

          case "F":
            return "9" == f ? "该课时已被系统自动确认完成。italki信用点数已经转入教师账户。" : "学生已确认该课时完成。";

          case "G":
            return "教师已对课时作出评价和反馈。";

          case "Z":
            return "4" == e.session_type ? "2" == e.operater ? "教师在该时间课时繁忙，课时请求未成功。" : "9" == e.operater ? "教师在该时间不可用，课时请求未成功。" : "该课时已经被 italki 取消。" : "该课时已经被 italki 取消。";

          case "8":
            return a(f, "学生声明该课时存在问题。", "教师声明该课时存在问题。", "");

          case "I":
            return "该课时正在争议处理中。";

          case "9":
            return a(f, "学生已请求取消该课时。", "教师已请求取消该课时。", "");

          case "X":
            return a(f, "学生已同意取消课时。该课时已被取消。", "教师已同意取消课时。该课时已被取消。", "该取消请求已自动过期。");
        }
        return "";
    },
    unique: function(e) {
        return e.filter(function(e, r, t) {
            return t.indexOf(e) === r;
        });
    },
    sessionCourseTitle: function(e) {
        var r = e.course_title;
        e.learn_language || e.language;
        return "TS200" == r ? "一对一辅导：" : r;
    },
    paymentHistoryDesc: function(e) {
        switch (e) {
          case 1001:
            return "购买 italki 信用点数";

          case 1002:
            return "手续费";

          case 1003:
            return "信用点数退还";

          case 1004:
            return "手续费退还";

          case 2001:
          case 3001:
            return "提现";

          case 3002:
            return "取款失败";

          case 3003:
            return "取款手续费返还";

          case 3004:
            return "提现手续费";

          case 3005:
            return "提现失败";

          case 4001:
          case 5001:
            return "支付课时";

          case 5002:
          case 5006:
            return "退款";

          case 5003:
            return "收到付款";

          case 5004:
            return "服务费";

          case 5005:
            return "支付课时";

          case 5007:
            return "收到付款";

          case 5008:
            return "服务费";

          case 6001:
            return "促销代码";

          case 6002:
            return "提现失败";

          case 7001:
            return "从教师钱包转账";

          case 7e3:
            return '"从教师钱包转移" undone';

          case 7003:
            return "部分信用冻结";

          case 7004:
            return "部分信用解冻";

          case 7006:
            return "部分信用冻结";

          case 7007:
            return "部分信用解冻";

          case 7008:
            return "学生钱包无效";

          case 7009:
            return "调整";

          case 8001:
            return "产品付款";

          case 8002:
            return "付款";

          case 9001:
            return "推荐人";

          case 10001:
            return "购买礼物卡";

          case 10002:
            return "礼物卡";

          case 10003:
            return "礼品卡已过期";
        }
    }
};